class Vue {
    constructor(options) {
        this.$options = options
        this._data = options.data
        this.initData()
    }

    initData() {
        const data = this._data
        const keys = Object.keys(data)
        // 将data里所有key代理到vue实例上
        for(let key of keys) {
            Object.defineProperty(this, key, {
                enumerable: true,
                configurable: true,
                get: function getterProxy () {
                    return data[key]
                },
                set: function setterProxy (val) {
                    data[key] = val
                }
            })
        }
    }
    
}